﻿using SqlSugar;

namespace DataModels.Entities.Base
{
    public class Properties
    {
        [SugarColumn(IsPrimaryKey = true)]
        public Guid UUID { get; set; } = Guid.NewGuid();

        /// <summary>
        /// 项目UUID
        /// </summary>
        public Guid ProjectUUID { get; set; }


        /// <summary>
        /// 楼栋号
        /// </summary>
        public string BuildingNo { get; set; }

        /// <summary>
        /// 单元号
        /// </summary>
        public string UnitNo { get; set; }

        /// <summary>
        /// 楼层号
        /// </summary>
        public string FloorNo { get; set; }

        /// <summary>
        /// 房号
        /// </summary>
        public string RoomNo { get; set; }

        /// <summary>
        /// 完整地址（自动计算）
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string FullAddress
        {
            get
            {
                var parts = new List<string>();

                if (!string.IsNullOrEmpty(BuildingNo))
                    parts.Add($"{BuildingNo}栋");

                if (!string.IsNullOrEmpty(UnitNo))
                    parts.Add($"{UnitNo}单元");

                if (!string.IsNullOrEmpty(FloorNo))
                    parts.Add($"{FloorNo}层");

                if (!string.IsNullOrEmpty(RoomNo))
                    parts.Add(RoomNo);

                return string.Join(" ", parts);
            }
        }
    }
}
